<template>
  <table>
    <tr>
      <td>课程名称</td>
      <td>课程介绍 </td>
      <td>课程老师</td>
    </tr>

    <tr v-for="(clas,index) in classes">
      <td>{{clas.className}}</td>
      <td>{{clas.classDesc}}</td>
      <td>{{clas.teacher}}</td>
    </tr>
  </table>
</template>

<script>
  import axios from 'axios'
  //设置让axios 携带cookie去请求后端
  axios.defaults.withCredentials=true
  export default {
    name: "",
    data(){
      return{
        classes:[]
      }
    },
    methods:{
      findAll:function () {
        axios.get("http://localhost:9999/credit-user/findClasses").then(res=>{
          if (res.data.code==200){
            this.classes = res.data.message;
          } else{
            alert(res.data.message)
            this.$router.push("/")
          }
        })
      }
    },
    mounted(){
      this.findAll();
    }
  }
</script>

<style scoped>

</style>
